//@author A0094511L Lu Si Hong
///@class GUI
///@Description This class is used to display the Main Window that is used by BOT
///				This class only contains logic that is related to the display of GUI
///				This class controls the signal emitted by UI, that is sent to Bot, the
///				the brain of BOT, and also allows feedback from Bot back to the UI by capturing
///				these signals through slots

#ifndef GUI_H
#define GUI_H

#include <QtWidgets/QMainWindow>
#include <QApplication>
#include "ui_gui.h"
#include <QString>
#include <QMessageBox>
#include "bot.h"
#include "CommonUtils.h"
#include <QShortcut>
#include <QtCore>
#include <QtGui>
#include <qcompleter.h>
#include <qstring.h>
#include "model.h"
#include <QAbstractTableModel>
#include <lineedit.h>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QxtGlobalShortcut>
#include <QGraphicsDropShadowEffect>
#include "OutputManager.h"
#include <QTimer>
#include <QDateTime>

class GUI : public QMainWindow
{
	Q_OBJECT

public:
	GUI(QWidget *parent = 0);
	~GUI();

private:
	QCompleter *comp;
	QAbstractItemModel *modelFromFile(const QString& fileName);
	QSystemTrayIcon* trayIcon;
	QxtGlobalShortcut* shortcut;
	Ui::GUIClass ui;
	//@brief This function connects the slots to signals for UI to Bot and from Bot to UI.
	void setUpConnections();
	//@brief This function is to set the styles of all the widgets in the QMainWindow
	void setStyles();
	//@brief Set up the help for all the relevant widgets in calendar
	void setHelp();
	void setupModel();
	Bot *BotControl;
	QAbstractTableModel *model;
	QShortcut *undoShortCut;
	QPixmap* tickLabel;
	QPixmap* crossLabel;
	QPixmap* overduePix;
	void createSystemTrayIcon();
	void createGlobalShortcut();
	bool _isHelpDisplayed;
	void initRemindersForToday();
	QString thingsToday;
	QTimer *timer;
	QString thingsOverdue;


	//EntriesManager manager;
private slots:
	//void receiveCommand1(QModelIndex);
	//@brief slot to receive command line signal from user from LineEdit
	void receiveCommand();
	//@brief slot to receive signal to display tasks
	void receiveDisplayInstructions();
	void displayCalendarDate(const QDate&);

	//@brief slot to receive signal to add tasks via calendar's date click
	void receiveCalendarCmd();
	void quitCmd();
	void showTime();
	void filterEventsfromClick();
	void filterTasksfromClick();
	void filterAllfromClick();

public slots:

	//@brief slot to receive signal to change color of days with events/tasks
	void receiveCalendarEntryExists(const QDate&);
	void displayHelpInput(const QString &);
	void undoCalled();
	void redoCalled();
	void undoFromCommandInput();
	void redoFromCommandInput();
	void undoFromCommandInput(QKeyEvent *e);
	void trayIconClicked(QSystemTrayIcon::ActivationReason reason);
	void toggleVisibility();
	void validCommandInput(const QString &text);
	void setLabel();
	//For text edit implementation
	void displayHelpInput();
	void validCommandInput();
	//void guiTabCheck();
};


#endif // GUI_H
